package com.shawn.baseappbygroovydsl.ui.views

import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.shawn.baseappbygroovydsl.R
import com.shawn.baseappbygroovydsl.bean.BeanTask
import com.shawn.baseappbygroovydsl.component.ItemDecorationTask
import com.shawn.baseappbygroovydsl.databinding.FragmentRecyclerviewBinding
import com.shawn.baseappbygroovydsl.ui.adapter.AdapterRecyclerViewStyle1
import com.shawn.baseappbygroovydsl.ui.base.FragmentBase
import com.shawn.baseappbygroovydsl.utils.UtilView

class RecyclerViewFragment  : FragmentBase<FragmentRecyclerviewBinding>(R.layout.fragment_recyclerview) {

    private val adapterDailyTask by lazy {
        AdapterRecyclerViewStyle1().apply {
            setOnItemClickListener { adapter, view, position ->

            }
        }
    }

    companion object {
        fun newInstance(): RecyclerViewFragment {
            val args = Bundle()
            val fragment = RecyclerViewFragment()
            fragment.arguments = args
            return fragment
        }
    }

    override fun onKeyCodeBack(): Boolean {
        return false
    }

    override fun statusBar() {

    }

    override fun lazyLoad() {
        mBind.recyclerView.layoutManager = LinearLayoutManager(context)
        mBind.recyclerView.adapter = adapterDailyTask
        mBind.recyclerView.setHasFixedSize(true)
        mBind.recyclerView.addItemDecoration(ItemDecorationTask())
        UtilView.cancelRvAnimation(mBind.recyclerView)

        val data = mutableListOf<BeanTask>()
        for (i in 0..5) {
            data.add(BeanTask("title$i", "desc$i",R.drawable.ic_launcher_background))
        }
        adapterDailyTask.submitList(data)
    }

    override fun initClick() {

    }

    override fun getData() {

    }

    override fun getBind(view: View): FragmentRecyclerviewBinding {
        return FragmentRecyclerviewBinding.bind(view)
    }
}